package com.hfb.mashibing.alip8.spring.shardingsphere.repository;

import com.hfb.mashibing.alip8.spring.shardingsphere.config.DataSourceContextHolder;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.apache.bcel.Repository;

@org.springframework.stereotype.Repository
@Slf4j
public class ManyDataSourceRepository extends Repository {


//    @Autowired
//    XXXMapper xxxMapper;

    public String insert(Object o){
        // 动态设置数据源
        long id = new Double((Math.random() + 0.1) * 100).longValue();
        log.debug("id:{}",id);
        String dataSourceType = DataSourceContextHolder.setDataSourceType(id);

        return dataSourceType;

    }

}
